package com.exp.irorichat.entity.requst;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.exp.irorichat.valid.AddGroup;
import com.exp.irorichat.valid.ListValue;
import com.exp.irorichat.valid.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 用户表
 * </p>
 *
 * @author universe7427
 * @since 2024-12-10
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="User对象", description="用户表")
public class UserReq implements Serializable {

    private static final long serialVersionUID = 1L;


    @NotNull(message = "修改必须指定id",groups = {UpdateGroup.class})
    @ApiModelProperty(value = "用户id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @NotBlank(message = "用户昵称必须提交",groups = {AddGroup.class,UpdateGroup.class})
    @ApiModelProperty(value = "用户昵称")
    private String name;

    @NotBlank(message = "头像不能为空",groups = {AddGroup.class})
    @URL(message = "logo必须是一个合法的url地址",groups={AddGroup.class,UpdateGroup.class})
    @ApiModelProperty(value = "用户头像")
    private String avatar;

    @NotNull(groups = {AddGroup.class, UpdateGroup.class})
    //自定义校验规则,值必须是0或1
    @ListValue(vals={0,1},groups = {AddGroup.class, UpdateGroup.class})
    @ApiModelProperty(value = "性别 1为男性，2为女性")
    private Integer sex;

    @NotEmpty(groups={AddGroup.class})
    @Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{9,15}$",
            message = "密码必须由字母和数字组成，不能含有空格且长度必须大于8位小于16位",
            groups={AddGroup.class,UpdateGroup.class})
    @ApiModelProperty(value = "密码")
    private String password;


}
